package com.hospital.demo.controller.gaoyuran;

import com.hospital.demo.model.gaoyuran.Application;
import com.hospital.demo.service.gaoyuran.ApplicationSer;
import com.hospital.demo.util.ResultUtils;
import com.hospital.demo.util.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/application")
@Api(tags={"G_申请表接口"})
public class ApplicationCon {

    @Autowired
     private ApplicationSer applicationSer;
    /**
     * 双查询
     */
    @GetMapping("/searchD")
    public ResultVO searchworker(Integer pid, Integer did) {
        Application application = new Application();
        if (pid != 0) {
            application.setPid(pid);
        }
        if (did != 0) {
            application.setDid(did);
        }
        List<Application> list = applicationSer.selectAppByD(application);
        return ResultUtils.success(list);
    }

    @ApiOperation(value = "获取全部申请表信息", notes = "")
    @GetMapping("/findAllapplication")
    private ResultVO findAllapplication() {
        return ResultUtils.success(applicationSer.findAllapplications());
    }
    @ApiOperation(value = "获取全部申请表信息", notes = "")
    @GetMapping("/findAllapplicationno")
    private ResultVO findAllapplicationno() {
        return ResultUtils.success(applicationSer.findAllapplicationsno());
    }
    @ApiOperation(value = "获取全部申请表信息", notes = "")
    @GetMapping("/findAllapplicationyes")
    private ResultVO findAllapplicationyes() {
        return ResultUtils.success(applicationSer.findAllapplicationsyes());
    }

    @ApiOperation(value = "通过id查询申请表信息", notes = "")
    @GetMapping("/findApplicationById")
    private ResultVO findApplicationById(@RequestParam(name = "aid", defaultValue = "-1") Integer aid ){
        return ResultUtils.success(applicationSer.findApplicationById(aid));
    }

    @ApiOperation(value = "添加申请表信息", notes = "")
    @PostMapping("/AddApplication")
    private ResultVO AddApplication(Application application) {
        return ResultUtils.success(applicationSer.AddApplication(application));
    }

    @ApiOperation(value = "更新申请表信息", notes = "")
    @PostMapping("/upDateApplication")
    private ResultVO upDateApplication(Application application) {
        return ResultUtils.success(applicationSer.upDateApplication(application));
    }


}
